"""
2023.6.26
Map模块，用于储存地图场景，读取、生成自制地图
"""
import configparser
import csv
import math

from PyQt5.Qt import *
import Main_interface
from bin.map_obstacle import obstacle as obs
from bin.map import Map
import pyqtgraph as pg
from bin import convert_lat_lon
from bin import output_window
from bin import route_planning_threading
from bin import track_obj


class MainCode(QMainWindow, Main_interface.Ui_MainWindow):
    def __init__(self):
        super(MainCode, self).__init__()
        # map界面
        self.trajectory = None
        self.display_route_ = None
        self.route_plan = None
        self.pen_0 = None
        self.win_0 = None
        self.vertical_layout_0 = None
        self.scatterItem_0 = None
        self.window = None
        self.preview_obs = None
        self.preview_map0 = None
        self.map_bound = None
        self.obs_bound = None
        self.scatterItem = None  # 存放鼠标按钮
        self.vertical_layout = None  # 垂直布局
        self.win = None  # 图形布局小部件
        self.pen = None  # 图形画笔
        self.obs_sum = []  # 存放障碍物图元
        self.new_obs = None  # 新建的障碍物
        self.ip = '192.168.1.102'  # 默认本机IP
        self.port = 8888  # 本机端口
        self.UDP_thread = None  # UDP线程
        self.UDP_lat_lon_coordinate = [-1, -1]  # 传输获得的经纬度坐标
        self.choose_dot_way_planning = 0  # 1为UDP传输， 2为鼠标选点
        self.mark_x_planning = -1
        self.mark_y_planning = -1
        self.thread_planning = None
        # 运动界面
        #
        self.setupUi(self)
        self.work_file = ""
        self.map = Map()
        self.mark_x = - 1.0
        self.mark_y = - 1.0
        self.mark_x_convert = - 1.0
        self.mark_y_convert = - 1.0
        self.click_obs = -1  # 被鼠标选中的障碍物索引
        self.choose_dot_way = 0  # 选择打点形式， 1表示鼠标取点， 0表示UDP传输

        # 添加按钮信号和槽
        self.pushButton.clicked.connect(self.create_new_map)
        self.pushButton_4.clicked.connect(self.choose_map)
        self.pushButton_2.clicked.connect(self.save_map)
        self.pushButton_3.clicked.connect(self.load_mao)
        self.pushButton_5.clicked.connect(self.capture_second_map_point)
        self.pushButton_6.clicked.connect(self.capture_fourth_map_point)
        self.pushButton_7.clicked.connect(self.capture_third_map_point)
        self.pushButton_8.clicked.connect(self.capture_first_map_point)
        self.pushButton_9.clicked.connect(self.generate_map_boundary)
        self.pushButton_10.clicked.connect(self.remove_map_boundary)
        self.pushButton_11.clicked.connect(self.preview_circular_obstacle)
        self.pushButton_12.clicked.connect(lambda: self.circular_obstacle_point_one(1))
        self.pushButton_13.clicked.connect(lambda: self.circular_obstacle_point_one(2))
        self.pushButton_14.clicked.connect(lambda: self.circular_obstacle_point_one(3))
        self.pushButton_15.clicked.connect(self.preview_map)
        self.pushButton_16.clicked.connect(self.refresh_obstacle)
        self.pushButton_17.clicked.connect(self.generate_obstacle)
        self.pushButton_18.clicked.connect(self.remove_obstacle)
        self.pushButton_19.clicked.connect(self.set_obstacle_safety_boundary)
        self.pushButton_20.clicked.connect(self.remove_all_obstacles)
        self.pushButton_20.setStyleSheet("background-color: rgb(209, 9, 71);")
        self.pushButton_21.clicked.connect(self.add_obstacle_vertex)
        self.pushButton_22.clicked.connect(self.preview_polygon_obstacle)
        self.pushButton_23.clicked.connect(self.save_other_file)
        self.pushButton_24.clicked.connect(self.clear_mark_point)
        self.pushButton_25.clicked.connect(lambda: self.create_new_obstacle(1))
        self.pushButton_26.clicked.connect(lambda: self.create_new_obstacle(2))
        self.pushButton_32.clicked.connect(self.init_output_window)
        self.pushButton_41.clicked.connect(self.preview_track)  # 展示生成的轨迹
        self.pushButton_42.clicked.connect(self.save_track)  # 保存生成的轨迹
        self.pushButton_43.clicked.connect(self.save_track_in_car)  # 保存车辆运行轨迹
        self.pushButton_38.clicked.connect(self.clear_mark_planning_point)
        self.pushButton_39.clicked.connect(self.linear_planning)
        self.pushButton_40.clicked.connect(self.route_planning)
        self.pushButton_32.setStyleSheet("QPushButton{border-image: url(./image/setting.jpg)}")
        self.lineEdit_9.setPlaceholderText("请选择文件")
        self.lineEdit_27.editingFinished.connect(self.exchange_UDP_connect)
        self.lineEdit_33.editingFinished.connect(self.exchange_UDP_connect)
        self.comboBox_3.currentTextChanged.connect(self.convert_lat_by_conf)
        self.comboBox_4.currentTextChanged.connect(self.choose_dot_way_exchange)
        self.comboBox_5.currentIndexChanged.connect(self.exchange_planning_point_way)
        self.tabWidget.currentChanged.connect(self.change_tab)
        # 绘制地图幕布
        self.init_map_screen()  # 初始化地图幕布
        self.init_mouse_pen()  # 初始化鼠标点按
        self.init_line_map()  # 初始化地图lineEdit链接
        self.init_map_word()  # 初始化地图LineEdit显示
        self.init_UDP()  # 初始化UDP接口
        self.init_planning_conf()
        self.init_planning_map()
        self.init_mouse_pen_planning()
        self.init_planning_line_edit()

    # 各链接函数
    # 鼠标点按事件
    def on_Mouse_Moved(self, evt):
        vb = self.pen.vb
        scene = evt.scenePos()
        if self.pen.sceneBoundingRect().contains(scene):
            mouse_point = vb.mapSceneToView(scene)
            x = round(float(mouse_point.x()), 4)
            y = round(float(mouse_point.y()), 4)
            if self.choose_dot_way == 1:
                self.mark_x = x
                self.mark_y = y
            if self.map.point_in_map(x, y):
                if self.map.choose_obs(x, y) == -1:
                    if self.choose_dot_way == 1:
                        self.scatterItem.addPoints([x], [y])
                else:
                    self.click_obs = self.map.choose_obs(x, y)
                    self.line_print_obs_point(self.click_obs)

    # 得到鼠标点击位置坐标，地图边界模块
    def focus_map_point(self, x):
        if x == 1:
            self.lineEdit_4.setText(str(self.mark_x))  # 1
            self.lineEdit_5.setText(str(self.mark_y))
        elif x == 2:
            self.lineEdit_3.setText(str(self.mark_x))  # 2
            self.lineEdit_6.setText(str(self.mark_y))
        elif x == 3:
            self.lineEdit_2.setText(str(self.mark_x))  # 3
            self.lineEdit_7.setText(str(self.mark_y))
        elif x == 4:
            self.lineEdit.setText(str(self.mark_x))  # 4
            self.lineEdit_8.setText(str(self.mark_y))

    # 链接lineEdit障碍物端函数
    def focus_obs_point(self, x):
        if x == 1:
            self.lineEdit_12.setText(str(self.mark_x))
            self.lineEdit_13.setText(str(self.mark_y))
            return
        elif x == 2:
            self.lineEdit_14.setText(str(self.mark_x))
            self.lineEdit_15.setText(str(self.mark_y))
            return
        elif x == 3:
            self.lineEdit_17.setText(str(self.mark_x))
            self.lineEdit_18.setText(str(self.mark_y))
            return
        elif x == 4:
            self.lineEdit_10.setText(str(self.mark_x))
            self.lineEdit_16.setText(str(self.mark_y))
        elif x == 5:
            self.lineEdit_21.setText(str(self.mark_x))
            self.lineEdit_22.setText(str(self.mark_y))
        if self.click_obs == -1:
            if self.new_obs is None:
                return
            if x == 0:
                self.new_obs.radius_circle = float(self.lineEdit_11.text())
                self.new_obs.center_circle[0] = float(self.lineEdit_10.text())
                self.new_obs.center_circle[1] = float(self.lineEdit_16.text())
                self.new_obs.init_obs()
                self.line_print_obs_point(-1)
        else:
            if self.map.map_obs[self.click_obs].obs_type == 1:
                if x == 0:
                    self.map.map_obs[self.click_obs].center_circle[0] = float(self.lineEdit_10.text())
                    self.map.map_obs[self.click_obs].center_circle[1] = float(self.lineEdit_16.text())
                    self.new_obs.radius_circle = float(self.lineEdit_11.text())
                    self.new_obs.init_obs()
                    self.line_print_obs_point(2)
                    self.draw_obs(self.pen)

    # 清空已标记的点
    def clear_mark_point(self):
        self.pen.removeItem(self.scatterItem)
        self.scatterItem.clear()
        self.scatterItem.update()
        self.pen.addItem(self.scatterItem)

    # 初始化地图界面
    def init_map_screen(self):
        self.vertical_layout = QVBoxLayout(self.widget_xy)  # 在widget位置创建垂直布局
        self.win = pg.GraphicsLayoutWidget(self.widget_xy)  # 创建图形布局小部件
        self.win.setBackground((164, 208, 106))  # 定义背景颜色
        self.vertical_layout.addWidget(self.win)  # 放入垂直布局
        self.pen = self.win.addPlot()  # 添加plot显示窗体
        self.pen.setAspectLocked()
        s1 = pg.ScatterPlotItem()
        s2 = pg.ScatterPlotItem()
        self.pen.showGrid(x=True, y=True)
        self.pen.setLabel(axis="left", text="<span style='font-size:16px;color:black;font-family: Arial'>y(m)</span>")
        self.pen.setLabel(axis="bottom", text="<span style='font-size:16px;color:black;font-family: Arial'>x(m)</span>")
        myPen = pg.mkPen({'color': (0, 255, 0), 'width': 5})
        myPen2 = pg.mkPen({'color': (255, 0, 0), 'width': 5})
        self.pen.addItem(s1, pen=myPen, name="y2")
        self.pen.addItem(s2, pen=myPen2, name="y4")

    # 初始化地图line链接
    def init_map_word(self):
        self.lineEdit_19.clear()
        self.lineEdit_19.setPlaceholderText("默认地图")
        self.lineEdit_4.clear()
        self.lineEdit_5.clear()
        self.lineEdit.clear()
        self.lineEdit_8.clear()
        self.lineEdit_3.clear()
        self.lineEdit_6.clear()
        self.lineEdit_2.clear()
        self.lineEdit_7.clear()
        self.lineEdit_4.setPlaceholderText('0.0')  # 1
        self.lineEdit_5.setPlaceholderText('0.0')
        self.lineEdit_3.setPlaceholderText('0.0')  # 2
        self.lineEdit_6.setPlaceholderText('0.0')
        self.lineEdit_2.setPlaceholderText('0.0')  # 3
        self.lineEdit_7.setPlaceholderText('0.0')
        self.lineEdit.setPlaceholderText('0.0')  # 4
        self.lineEdit_8.setPlaceholderText('0.0')
        self.checkBox.setChecked(True)  # 显示地图边界
        self.checkBox_2.setChecked(True)  # 显示所有障碍物
        self.textBrowser_2.setPlaceholderText('请选择障碍物或添加障碍物')  # 多边形障碍物line
        self.lineEdit_24.setText('默认多边形障碍物')
        self.lineEdit_21.setPlaceholderText('0.0')
        self.lineEdit_22.setPlaceholderText('0.0')
        self.lineEdit_23.setText('默认圆形障碍物')
        self.lineEdit_10.setPlaceholderText('0.0')  # 圆心x
        self.lineEdit_16.setPlaceholderText('0.0')  # 圆心y
        self.lineEdit_11.setPlaceholderText('0.0')  # 圆半径
        self.lineEdit_12.setPlaceholderText('0.0')  # 圆1
        self.lineEdit_13.setPlaceholderText('0.0')
        self.lineEdit_14.setPlaceholderText('0.0')  # 圆2
        self.lineEdit_15.setPlaceholderText('0.0')
        self.lineEdit_17.setPlaceholderText('0.0')  # 圆3
        self.lineEdit_18.setPlaceholderText('0.0')
        self.lineEdit_20.setPlaceholderText('0.0')  # 安全边界
        self.lineEdit_25.setPlaceholderText('0')  # 障碍物个数

    # 以下包括输入输出lineEdit,控制输入精度
    def init_line_map(self):
        # 设置校验器
        # double = QDoubleValidator()
        # double.setNotation(QDoubleValidator.StandardNotation)
        # double.setDecimals(4)
        # self.lineEdit_4.setValidator(double)
        # self.lineEdit_5.setValidator(double)
        # 地图边界界面lineEdit链接
        self.lineEdit_4.returnPressed.connect(lambda: self.focus_map_point(1))  # 1
        self.lineEdit_5.returnPressed.connect(lambda: self.focus_map_point(1))
        self.lineEdit_3.returnPressed.connect(lambda: self.focus_map_point(2))  # 2
        self.lineEdit_6.returnPressed.connect(lambda: self.focus_map_point(2))
        self.lineEdit_2.returnPressed.connect(lambda: self.focus_map_point(3))  # 3
        self.lineEdit_7.returnPressed.connect(lambda: self.focus_map_point(3))
        self.lineEdit.returnPressed.connect(lambda: self.focus_map_point(4))  # 4
        self.lineEdit_8.returnPressed.connect(lambda: self.focus_map_point(4))
        self.lineEdit_19.editingFinished.connect(lambda: self.line_print_map_name(self.lineEdit_19.text()))
        # 障碍物边界界面lineEdit链接
        self.lineEdit_10.returnPressed.connect(lambda: self.focus_obs_point(4))  # 圆心
        self.lineEdit_16.returnPressed.connect(lambda: self.focus_obs_point(4))
        self.lineEdit_11.returnPressed.connect(lambda: self.focus_obs_point(0))  # 半径
        self.lineEdit_12.returnPressed.connect(lambda: self.focus_obs_point(1))  # 1
        self.lineEdit_13.returnPressed.connect(lambda: self.focus_obs_point(1))
        self.lineEdit_14.returnPressed.connect(lambda: self.focus_obs_point(2))  # 2
        self.lineEdit_15.returnPressed.connect(lambda: self.focus_obs_point(2))
        self.lineEdit_17.returnPressed.connect(lambda: self.focus_obs_point(3))  # 3
        self.lineEdit_18.returnPressed.connect(lambda: self.focus_obs_point(3))
        self.lineEdit_21.returnPressed.connect(lambda: self.focus_obs_point(5))  # 增加顶点
        self.lineEdit_22.returnPressed.connect(lambda: self.focus_obs_point(5))
        self.lineEdit_23.editingFinished.connect(lambda: self.line_print_obs_name(1))  # 圆形障碍物名称
        self.lineEdit_24.editingFinished.connect(lambda: self.line_print_obs_name(2))  # 多边形障碍物名称
        self.checkBox.stateChanged.connect(self.display_map)
        self.checkBox_2.stateChanged.connect(self.display_obs)
        # 创建地图边界图元
        pen = QPen()
        pen.setColor(Qt.black)
        pen.setWidth(2)
        self.map_bound = QGraphicsPolygonItem()
        self.map_bound.setPen(pen)
        # 创建障碍物图元
        pen2 = QPen()
        pen2.setColor(Qt.black)
        pen2.setWidth(3)
        self.obs_bound = QGraphicsPolygonItem()
        self.obs_bound.setPen(pen2)

    # 初始化map鼠标点按模块
    def init_mouse_pen(self):
        self.win.scene().sigMouseClicked.connect(self.on_Mouse_Moved)
        # 定义画笔颜色
        brush = pg.mkBrush(color=(23, 22, 21))
        self.scatterItem = pg.ScatterPlotItem(pen=None, size=4, brush=brush, symbol='s')  # 标点按键列表
        self.pen.addItem(self.scatterItem)

    # 显示读取的文件名
    def line_print_file_name(self, file):
        self.lineEdit_9.clear()
        self.lineEdit_9.setText(file)

    # 地图详情显示
    def print_map_inf(self, inf):
        self.textBrowser.append(str(inf))

    # 输出多边形障碍物信息
    def print_obs_inf(self, inf):
        self.textBrowser_2.append(str(inf))

    # 展示地图名称
    def line_print_map_name(self, name):
        self.lineEdit_19.clear()
        self.lineEdit_19.setText(name)
        self.map.name = name

    # 展示地图四个点位坐标
    def line_print_map_point(self):
        if not len(self.map.map_boundary) == 0:
            first_point = self.map.map_boundary[0]
            self.lineEdit_4.setText(str(first_point[0]))  # 1
            self.lineEdit_5.setText(str(first_point[1]))
        if not len(self.map.map_boundary) == 0 and not len(self.map.map_boundary) == 1:
            sec_point = self.map.map_boundary[1]
            self.lineEdit_3.setText(str(sec_point[0]))  # 2
            self.lineEdit_6.setText(str(sec_point[1]))
        if len(self.map.map_boundary) == 4 or len(self.map.map_boundary) == 3:
            thi_point = self.map.map_boundary[2]
            self.lineEdit_2.setText(str(thi_point[0]))  # 3
            self.lineEdit_7.setText(str(thi_point[1]))
        if len(self.map.map_boundary) == 4:
            fou_point = self.map.map_boundary[3]
            self.lineEdit.setText(str(fou_point[0]))  # 4
            self.lineEdit_8.setText(str(fou_point[1]))

    # 更新地图障碍物名称
    def line_print_obs_name(self, mode):
        if self.click_obs == -1:
            if mode == 1 and self.new_obs.obs_type == 2:
                self.new_obs.name = self.lineEdit_23.text()
            elif mode == 2 and self.new_obs.obs_type == 1:
                self.new_obs.name = self.lineEdit_24.text()
        else:
            if self.map.map_obs[self.click_obs].obs_type == 1 and mode == 2:
                self.map.map_obs[self.click_obs].name = self.lineEdit_24.text()
            elif mode == 1 and self.map.map_obs[self.click_obs].obs_type == 2:
                self.map.map_obs[self.click_obs].name = self.lineEdit_23.text()

    # 障碍物界面展示选定障碍物详细信息
    def line_print_obs_point(self, ob):
        if ob == -1:
            self.lineEdit_23.clear()
            self.lineEdit_10.clear()
            self.lineEdit_16.clear()
            self.lineEdit_11.clear()
            self.lineEdit_12.clear()
            self.lineEdit_13.clear()
            self.lineEdit_14.clear()
            self.lineEdit_15.clear()
            self.lineEdit_17.clear()
            self.lineEdit_18.clear()
            self.lineEdit_24.clear()
            self.textBrowser_2.clear()
            if not self.new_obs is None:
                self.lineEdit_20.clear()
                self.lineEdit_20.setText(str(self.new_obs.obs_safe_distance))
                if self.new_obs.obs_type == 1:
                    inf = f"未添加的障碍物:{self.new_obs.name}\nX:\t\tY:\n"
                    for i in self.new_obs.obs_point:
                        inf += f"{i[0]}\t\t{i[1]}\n"
                    self.print_obs_inf(inf)
                    self.lineEdit_24.setText(str(self.new_obs.name))
                elif self.new_obs.obs_type == 2:
                    self.lineEdit_23.setText(str(self.new_obs.name))
                    self.lineEdit_10.setText(str(self.new_obs.center_circle[0]))
                    self.lineEdit_16.setText(str(self.new_obs.center_circle[1]))
                    self.lineEdit_11.setText(str(self.new_obs.radius_circle))
                    if not len(self.new_obs.obs_point) == 0:
                        self.lineEdit_12.setText(str(self.new_obs.obs_point[0][0]))
                        self.lineEdit_13.setText(str(self.new_obs.obs_point[0][1]))
                    if not len(self.new_obs.obs_point) == 0 and not len(self.new_obs.obs_point) == 1:
                        self.lineEdit_14.setText(str(self.new_obs.obs_point[1][0]))
                        self.lineEdit_15.setText(str(self.new_obs.obs_point[1][1]))
                    if len(self.new_obs.obs_point) == 3:
                        self.lineEdit_17.setText(str(self.new_obs.obs_point[2][0]))
                        self.lineEdit_18.setText(str(self.new_obs.obs_point[2][1]))
            return
        self.lineEdit_20.clear()
        self.lineEdit_20.setText(str(self.map.map_obs[ob].obs_safe_distance))
        if self.map.map_obs[ob].obs_type == 1:
            self.lineEdit_23.clear()
            self.lineEdit_10.clear()
            self.lineEdit_16.clear()
            self.lineEdit_11.clear()
            self.lineEdit_12.clear()
            self.lineEdit_13.clear()
            self.lineEdit_14.clear()
            self.lineEdit_15.clear()
            self.lineEdit_17.clear()
            self.lineEdit_18.clear()
            self.lineEdit_24.clear()
            self.textBrowser_2.clear()
            inf = f"X:\t\tY:\n"
            for i in self.map.map_obs[ob].obs_point:
                inf += f"{i[0]}\t\t{i[1]}\n"
            self.print_obs_inf(inf)
            self.lineEdit_24.setText(str(self.map.map_obs[ob].name))
        elif self.map.map_obs[ob].obs_type == 2:
            self.lineEdit_24.clear()
            self.textBrowser_2.clear()
            self.lineEdit_23.setText(str(self.map.map_obs[ob].name))
            self.lineEdit_10.setText(str(self.map.map_obs[ob].center_circle[0]))
            self.lineEdit_16.setText(str(self.map.map_obs[ob].center_circle[1]))
            self.lineEdit_11.setText(str(self.map.map_obs[ob].radius_circle))
            if not len(self.map.map_obs[ob].obs_point) == 0:
                self.lineEdit_12.setText(str(self.map.map_obs[ob].obs_point[0][0]))
                self.lineEdit_13.setText(str(self.map.map_obs[ob].obs_point[0][1]))
            if not len(self.map.map_obs[ob].obs_point) == 0 and not len(self.map.map_obs[ob].obs_point) == 1:
                self.lineEdit_14.setText(str(self.map.map_obs[ob].obs_point[1][0]))
                self.lineEdit_15.setText(str(self.map.map_obs[ob].obs_point[1][1]))
            if len(self.map.map_obs[ob].obs_point) == 3:
                self.lineEdit_17.setText(str(self.map.map_obs[ob].obs_point[2][0]))
                self.lineEdit_18.setText(str(self.map.map_obs[ob].obs_point[2][1]))

    # 读取文件
    def choose_map(self):
        fname, ftype = QFileDialog.getOpenFileNames(self, "open File", '../', 'csv(*.csv)')
        # directory = QFileDialog.getExistingDirectory(self, "选取文件夹", "./")
        if fname:
            self.work_file = fname[0]
            self.line_print_file_name(self.work_file)

    # 创建新地图
    def create_new_map(self):
        self.map = Map()
        self.map.refresh_map()
        self.work_file = ''
        self.line_print_file_name('')
        self.init_map_word()
        self.line_print_obs_point(-1)
        self.draw_obs(self.pen)
        self.clear_mark_point()
        self.pen.removeItem(self.map_bound)
        self.pen.clear()

    # 另存为
    def save_other_file(self):
        file_name, o = QFileDialog.getSaveFileName(self, "文件保存", "./", 'csv(*.csv)')
        try:
            print(file_name)
            if file_name:
                self.map.refresh_map()
                self.map.save_map(file_name)
                if self.lineEdit_9.text() == '':
                    self.line_print_file_name(file_name)
                    self.work_file = file_name
            else:
                self.line_print_file_name("请选择文件")
        except:
            print("另存为文件错误")

    # 保存地图
    def save_map(self):
        if self.work_file:
            self.map.refresh_map()
            self.map.save_map(self.work_file)
        else:
            self.save_other_file()

    # 地图边界展示
    def draw_map(self, pen0):
        pen0.removeItem(self.map_bound)
        # 创建地图边界图元
        pen = QPen()
        pen.setWidth(0)
        brush = pg.mkBrush(color=(255, 255, 255))
        self.map_bound = QGraphicsPolygonItem()
        self.map_bound.setBrush(brush)
        self.map_bound.setPen(pen)
        list1 = []
        for i in self.map.map_boundary:
            l1 = QPointF(i[0], i[1])
            list1.append(l1)
        map_polygon = QPolygonF(list1)
        self.map_bound.setPolygon(map_polygon)
        pen0.addItem(self.map_bound)

    # 障碍物展示
    # 由于添加图元无法单独选定并显示绑定的相关信息，采用存放所有障碍物图元并遍历的方式刷新障碍物
    # 构想可以继承障碍物图元，在其内加入对应的自定义obs类，可使图元与障碍物信息绑定      未实现
    def draw_obs(self, pen_0):
        for i in self.obs_sum:
            pen_0.removeItem(i)
        self.obs_sum.clear()
        pen1 = QPen()
        pen1.setWidth(0)
        pen = pg.mkBrush(color=(0, 0, 0))
        for ob in self.map.map_obs:
            if ob.obs_type == 1:
                ob_draw = QGraphicsPolygonItem()
                ob_draw.setBrush(pen)
                ob_draw.setPen(pen1)
                list1 = []
                for i in ob.obs_point:
                    l1 = QPointF(i[0], i[1])
                    list1.append(l1)
                obs_polygon = QPolygonF(list1)
                ob_draw.setPolygon(obs_polygon)
                self.obs_sum.append(ob_draw)
            elif ob.obs_type == 2:
                x1 = ob.center_circle[0] - ob.radius_circle
                y1 = ob.center_circle[1] - ob.radius_circle
                ob_draw = QGraphicsEllipseItem(x1, y1, ob.radius_circle * 2, ob.radius_circle * 2)
                ob_draw.setPen(pen1)
                ob_draw.setBrush(pen)
                self.obs_sum.append(ob_draw)
        for i in self.obs_sum:
            pen_0.addItem(i)
        if pen_0 == self.pen:
            self.pen.removeItem(self.scatterItem)
            self.pen.addItem(self.scatterItem)

    # 载入地图
    def load_mao(self):
        if not not self.work_file:
            self.map = Map()
            self.map.load_map(self.work_file)
            self.line_print_file_name(self.work_file)
            self.line_print_map_name(self.map.name)
            self.line_print_map_point()
            self.pen.clear()
            self.draw_map(self.pen)
            self.draw_obs(self.pen)
            self.lineEdit_25.setText(str(self.map.num_obs))
            self.clear_mark_point()
            self.pen_0.clear()
            self.draw_map(self.pen_0)
            self.draw_obs(self.pen_0)
            self.clear_mark_planning_point()

    # 获取地图的一点
    def capture_first_map_point(self):
        x1 = self.lineEdit_4.text()
        y1 = self.lineEdit_5.text()
        if len(self.map.map_boundary) == 0:
            self.map.map_boundary.append([float(x1), float(y1)])
        else:
            self.map.map_boundary[0] = [float(x1), float(y1)]
        inf = f"已获取地图第一点X：{x1},Y：{y1}"
        self.print_map_inf(inf)
        self.draw_map(self.pen)

    def capture_second_map_point(self):
        x1 = self.lineEdit_3.text()
        y1 = self.lineEdit_6.text()
        if len(self.map.map_boundary) == 0 or len(self.map.map_boundary) == 1:
            self.map.map_boundary.append([float(x1), float(y1)])
        else:
            self.map.map_boundary[1] = [float(x1), float(y1)]
        inf = f"已获取地图第二点X：{x1},Y：{y1}"
        self.print_map_inf(inf)
        self.draw_map(self.pen)

    def capture_third_map_point(self):
        x1 = self.lineEdit_2.text()
        y1 = self.lineEdit_7.text()
        if len(self.map.map_boundary) <= 2:
            self.map.map_boundary.append([float(x1), float(y1)])
        else:
            self.map.map_boundary[2] = [float(x1), float(y1)]
        inf = f"已获取地图第三点X：{x1},Y：{y1}"
        self.print_map_inf(inf)
        self.draw_map(self.pen)

    def capture_fourth_map_point(self):
        x1 = self.lineEdit.text()
        y1 = self.lineEdit_8.text()
        if len(self.map.map_boundary) <= 3:
            self.map.map_boundary.append([float(x1), float(y1)])
        else:
            self.map.map_boundary[3] = [float(x1), float(y1)]
        inf = f"已获取地图第四点X：{x1},Y：{y1}"
        self.print_map_inf(inf)
        self.draw_map(self.pen)

    # 生成地图边界
    def generate_map_boundary(self):
        self.map.map_boundary.clear()
        x1 = self.lineEdit_4.text()  # 1
        y1 = self.lineEdit_5.text()
        if x1 == '' or y1 == '':
            return
        self.map.map_boundary.append([float(x1), float(y1)])
        x2 = self.lineEdit_3.text()  # 2
        y2 = self.lineEdit_6.text()
        if x2 == '' or y2 == '':
            return
        self.map.map_boundary.append([float(x2), float(y2)])
        x3 = self.lineEdit_2.text()  # 3
        y3 = self.lineEdit_7.text()
        if x3 == '' or y3 == '':
            return
        self.map.map_boundary.append([float(x3), float(y3)])
        x4 = self.lineEdit.text()  # 4
        y4 = self.lineEdit_8.text()
        if x4 == '' or y4 == '':
            return
        self.map.map_boundary.append([float(x4), float(y4)])
        inf = f"已创建新地图边界：\nX:\t\tY:\t\t\n"
        inf += f"{x1}\t\t{y1}\n{x2}\t\t{y2}\n{x3}\t\t{y3}\n{x4}\t\t{y4}"
        self.print_map_inf(inf)
        self.draw_map(self.pen)
        self.clear_mark_point()
        self.draw_obs(self.pen)

    # 删除地图边界，
    def remove_map_boundary(self):
        self.map.map_boundary.clear()
        self.init_map_word()
        self.map.name = '默认地图'
        self.pen.clear()
        self.draw_map(self.pen)

    # 刷新障碍物
    def refresh_obstacle(self):
        self.map.refresh_map()
        self.lineEdit_25.clear()
        self.lineEdit_25.setText(str(self.map.num_obs))

    # 删除所有障碍物
    def remove_all_obstacles(self):
        for i in self.obs_sum:
            self.pen.removeItem(i)
        self.map.map_obs.clear()
        self.map.refresh_map()
        self.pen.clear()
        self.draw_map(self.pen)
        # self.draw_obs(self.pen)
        self.line_print_obs_point(-1)
        self.lineEdit_25.setText(str(self.map.num_obs))
        self.pen.removeItem(self.scatterItem)
        self.pen.addItem(self.scatterItem)

    # 更改圆形障碍物点
    def circular_obstacle_point_one(self, mode):
        if mode == 1:
            x1 = self.lineEdit_12.text()
            y1 = self.lineEdit_13.text()
        elif mode == 2:
            x1 = self.lineEdit_14.text()
            y1 = self.lineEdit_15.text()
        elif mode == 3:
            x1 = self.lineEdit_17.text()
            y1 = self.lineEdit_18.text()
        else:
            x1, y1 = 0.0, 0.0
        x1 = float(x1)
        y1 = float(y1)
        if self.click_obs == -1:
            if self.new_obs is None:
                self.new_obs = obs()
            self.new_obs.obs_type = 2
            for i in range(3 - len(self.new_obs.obs_point)):
                self.new_obs.add_obs_point(0.0, 0.0)
            if mode == 1:
                self.new_obs.obs_point[0][0] = float(x1)
                self.new_obs.obs_point[0][1] = float(y1)
            elif mode == 2:
                self.new_obs.obs_point[1][0] = float(x1)
                self.new_obs.obs_point[1][1] = float(y1)
            elif mode == 3:
                self.new_obs.obs_point[2][0] = float(x1)
                self.new_obs.obs_point[2][1] = float(y1)
        else:
            if self.map.map_obs[self.click_obs].obs_type == 2:
                if mode == 1:
                    self.map.map_obs[self.click_obs].obs_point[0][0] = float(x1)
                    self.map.map_obs[self.click_obs].obs_point[0][1] = float(y1)
                elif mode == 2:
                    self.map.map_obs[self.click_obs].obs_point[1][0] = float(x1)
                    self.map.map_obs[self.click_obs].obs_point[1][1] = float(y1)
                elif mode == 3:
                    self.map.map_obs[self.click_obs].obs_point[2][0] = float(x1)
                    self.map.map_obs[self.click_obs].obs_point[2][1] = float(y1)
                self.map.map_obs[self.click_obs].init_obs()
                self.map.refresh_map()
                self.draw_obs(self.pen)
            elif self.map.map_obs[self.click_obs].obs_type == 1:
                return

    # 预览地图
    def preview_map(self):
        if self.pushButton_15.isChecked():
            pen3 = QPen()
            pen3.setWidth(0)
            brush3 = pg.mkBrush(color=(255, 255, 255))
            self.preview_map0 = QGraphicsPolygonItem()
            self.preview_map0.setPen(pen3)
            self.preview_map0.setBrush(brush3)
            list1 = []
            x1 = self.lineEdit_4.text()  # 1
            y1 = self.lineEdit_5.text()
            list1.append(QPointF(float(x1), float(y1)))
            x2 = self.lineEdit_3.text()  # 2
            y2 = self.lineEdit_6.text()
            list1.append(QPointF(float(x2), float(y2)))
            x3 = self.lineEdit_2.text()  # 3
            y3 = self.lineEdit_7.text()
            list1.append(QPointF(float(x3), float(y3)))
            x4 = self.lineEdit.text()  # 4
            y4 = self.lineEdit_8.text()
            list1.append(QPointF(float(x4), float(y4)))
            polygon = QPolygonF(list1)
            self.preview_map0.setPolygon(polygon)
            self.pen.addItem(self.preview_map0)
            self.preview_map0.setVisible(True)
        else:
            self.preview_map0.setVisible(False)

    # 预览圆形障碍物
    def preview_circular_obstacle(self):
        if self.new_obs is None:
            return
        self.pen.removeItem(self.preview_obs)
        if self.pushButton_11.isChecked():
            pen1 = QPen()
            pen1.setWidth(0)
            pen = pg.mkBrush(color=(0, 0, 0))
            if self.new_obs.obs_type == 2:
                x1 = self.lineEdit_12.text()
                y1 = self.lineEdit_13.text()
                x2 = self.lineEdit_14.text()
                y2 = self.lineEdit_15.text()
                x3 = self.lineEdit_17.text()
                y3 = self.lineEdit_18.text()
                te = obs()
                te.obs_type = 2
                te.add_obs_point(x1, y1)
                te.add_obs_point(x2, y2)
                te.add_obs_point(x3, y3)
                te.init_obs()
                x = te.center_circle[0] - te.radius_circle
                y = te.center_circle[1] - te.radius_circle
                self.preview_obs = QGraphicsEllipseItem(x, y, te.radius_circle * 2, te.radius_circle * 2)
                self.preview_obs.setPen(pen1)
                self.preview_obs.setBrush(pen)
                self.pen.addItem(self.preview_obs)
                self.preview_obs.setVisible(True)
        else:
            self.preview_obs.setVisible(False)

    # 预览多边形障碍物
    def preview_polygon_obstacle(self):
        if self.new_obs is None:
            return
        self.pen.removeItem(self.preview_obs)
        if self.pushButton_22.isChecked():
            pen1 = QPen()
            pen1.setWidth(0)
            pen = pg.mkBrush(color=(0, 0, 0))
            if self.new_obs.obs_type == 1:
                self.preview_obs = QGraphicsPolygonItem()
                self.preview_obs.setPen(pen1)
                self.preview_obs.setBrush(pen)
                list1 = []
                for i in self.new_obs.obs_point:
                    list1.append(QPointF(i[0], i[1]))
                polygon = QPolygonF(list1)
                self.preview_obs.setPolygon(polygon)
                self.pen.addItem(self.preview_obs)
                self.preview_obs.setVisible(True)
        else:
            self.preview_obs.setVisible(False)

    # 增加多边形障碍物点
    def add_obstacle_vertex(self):
        x1 = float(self.lineEdit_21.text())
        y1 = float(self.lineEdit_22.text())
        if self.click_obs == -1:
            if self.new_obs is None:
                self.new_obs = obs()
            self.new_obs.obs_type = 1
            self.new_obs.add_obs_point(x1, y1)
            self.print_obs_inf(f"新建障碍物点X:{x1},Y:{y1}")
        else:
            self.map.map_obs[self.click_obs].add_obs_point(x1, y1)
            self.print_obs_inf(f"多边形障碍物增加顶点X:{x1},Y:{y1}")
            self.map.refresh_map()
            self.draw_obs(self.pen)

    # 设置障碍物安全边界
    def set_obstacle_safety_boundary(self):
        if self.click_obs == -1:
            self.new_obs.obs_safe_distance = float(self.lineEdit_20.text())
        else:
            self.map.map_obs[self.click_obs].obs_safe_distance = float(self.lineEdit_20.text())

    # 创建新障碍物
    def create_new_obstacle(self, mode):
        self.click_obs = -1
        self.new_obs = obs()
        if mode == 1:
            self.new_obs.obs_type = 2
        elif mode == 2:
            self.new_obs.obs_type = 1
        self.line_print_obs_point(-1)

    # 生成障碍物
    def generate_obstacle(self):
        if self.new_obs is None:
            return
        if self.new_obs.obs_type == 2:
            if not self.lineEdit_23.text() == '':
                self.new_obs.name = self.lineEdit_23.text()
            self.circular_obstacle_point_one(1)
            self.circular_obstacle_point_one(2)
            self.circular_obstacle_point_one(3)
            self.new_obs.init_obs()
        elif self.new_obs.obs_type == 1:
            if not self.lineEdit_24.text() == '':
                self.new_obs.name = self.lineEdit_24.text()
        self.map.add_obs_in_map(self.new_obs)
        self.map.refresh_map()
        self.draw_obs(self.pen)
        self.pen.removeItem(self.scatterItem)
        self.pen.addItem(self.scatterItem)
        self.new_obs = None

    # 删除障碍物
    def remove_obstacle(self):
        self.map.delete_obs(self.click_obs)
        self.map.refresh_map()
        self.pen.clear()
        self.draw_map(self.pen)
        self.draw_obs(self.pen)
        self.line_print_obs_point(-1)
        self.lineEdit_25.setText(str(self.map.num_obs))

    # 显示地图边界
    def display_map(self):
        if self.checkBox.isChecked():
            self.map_bound.setVisible(True)
        else:
            self.map_bound.setVisible(False)

    # 展示障碍物
    def display_obs(self):
        if self.checkBox_2.isChecked():
            for i in self.obs_sum:
                i.setVisible(True)
        else:
            for i in self.obs_sum:
                i.setVisible(False)

    # udp端口，读取经纬度，转换为坐标轴，多线程
    def init_UDP(self):
        try:
            self.ip = convert_lat_lon.ip_now()
        except:
            self.lineEdit_33.setText("本地IP初始化失败")
            self.ip = "127.0.0.1"
        self.lineEdit_33.setText(self.ip)
        self.lineEdit_27.setText(str(self.port))
        config1 = configparser.ConfigParser()
        config1.read('./conf/reference_coordinate.conf')
        date = config1.sections()
        for i in date:
            self.comboBox_3.addItem(i)
        self.UDP_thread = convert_lat_lon.UDP_connect(self.ip, self.port)
        self.UDP_thread.signal_receive.connect(self.display_date_from_UDP)
        self.UDP_thread.start()

    def exchange_UDP_connect(self):
        self.port = int(self.lineEdit_27.text())
        self.UDP_thread.new_port = int(self.port)
        self.ip = str(self.lineEdit_33.text())
        self.UDP_thread.new_ip = self.ip

    def convert_lat_by_conf(self):
        current_dis = self.comboBox_3.currentText()
        if current_dis == '':
            pass
        else:
            self.mark_x_convert, self.mark_y_convert = convert_lat_lon.GPS_to_XY(self.UDP_lat_lon_coordinate[0],
                                                                                 self.UDP_lat_lon_coordinate[1],
                                                                                 current_dis)
            x = round(self.mark_x_convert, 2)
            y = round(self.mark_y_convert, 2)
            self.lineEdit_29.setText(str([x, y]))
            if self.choose_dot_way == 0:
                if self.UDP_lat_lon_coordinate[0] == -1:
                    pass
                else:
                    self.mark_x = self.mark_x_convert
                    self.mark_y = self.mark_y_convert
                    self.scatterItem.addPoints([self.mark_x], [self.mark_y])
            if self.choose_dot_way_planning == 1:
                if not self.UDP_lat_lon_coordinate[0] == -1:
                    self.mark_x_planning = self.mark_x_convert
                    self.mark_y_planning = self.mark_y_convert
                    self.scatterItem_0.addPoints([self.mark_x], [self.mark_y])

    def display_date_from_UDP(self, date):
        self.UDP_lat_lon_coordinate[0] = date[1]
        self.UDP_lat_lon_coordinate[1] = date[2]
        try:
            self.window.lat_lon = self.UDP_lat_lon_coordinate
        except:
            print("暂未打开设置window")
        self.lineEdit_28.setText(str(self.UDP_lat_lon_coordinate))
        self.convert_lat_by_conf()

    def init_output_window(self):
        self.window = output_window.Ui_Dialog()
        self.window.lat_lon = self.UDP_lat_lon_coordinate
        self.window.exec_()
        self.comboBox_3.clear()
        config1 = configparser.ConfigParser()
        config1.read('./conf/reference_coordinate.conf')
        date = config1.sections()
        for i in date:
            self.comboBox_3.addItem(i)

    def choose_dot_way_exchange(self):
        self.choose_dot_way = self.comboBox_4.currentIndex()
        if self.choose_dot_way == 1 and not self.UDP_lat_lon_coordinate[0] == -1:
            self.mark_x = self.mark_x_convert
            self.mark_y = self.mark_y_convert
            self.scatterItem.addPoints([self.mark_x], [self.mark_y])

    ####################################################################################################
    # 轨迹规划界面

    def init_planning_conf(self):
        filename = './conf/target_type.conf'
        config0 = configparser.ConfigParser()
        config0.read(filename)
        date = config0.sections()
        for i in date:
            self.comboBox_6.addItem(i)

    def save_track(self):
        file_name, o = QFileDialog.getSaveFileName(self, "文件保存", "../", 'csv(*.csv)')
        if file_name:
            with open('Trajectory_data.csv', 'r', encoding='utf-8') as f:
                with open(file_name, 'w', encoding='utf-8') as w:
                    reader = csv.reader(f, skipinitialspace=True)
                    writer = csv.writer(w, lineterminator='\n')
                    for row in reader:
                        writer.writerow(row)

    def save_track_in_car(self):
        file_name, o = QFileDialog.getSaveFileName(self, "文件保存", "../", 'csv(*.csv)')
        x = 0
        y = 0
        h = 0
        if file_name:
            with open('Trajectory_data.csv', 'r', encoding='utf-8') as f:
                with open(file_name, 'w', encoding='utf-8') as w:
                    reader = csv.reader(f, skipinitialspace=True)
                    writer = csv.writer(w, lineterminator='\n')
                    i = 0
                    for row in reader:
                        if i == 1:
                            x = float(row[0])
                            y = float(row[1])
                            h = float(row[3])
                        if i >= 1:
                            row[0] = str(float(row[0]) - x)
                            row[1] = str(float(row[1]) - y)
                            h0 = float(row[3]) - h
                            if h0 < 0:
                                h0 += 2 * math.pi
                            row[3] = str(h0)
                        writer.writerow(row)
                        i += 1

    def preview_track(self):
        if self.pushButton_41.isChecked():
            self.pen_0.removeItem(self.trajectory)
            file_name = 'Trajectory_data.csv'
            self.display_route_ = track_obj.Track()
            self.display_route_.read_csv(file_name)
            x_list, y_list = self.display_route_.get_x_y()
            self.trajectory = pg.PlotCurveItem(x_list, y_list,
                                               pen=pg.mkPen(color=(0, 0, 100), width=2, symbolBrush='r'))
            self.pen_0.addItem(self.trajectory)
        else:
            self.pen_0.removeItem(self.trajectory)

    def get_start_end_(self):
        start_point, end_point = [0, 0, 0], [0, 0, 0]
        try:
            start_point[0] = float(self.lineEdit_26.text())
            start_point[1] = float(self.lineEdit_30.text())
            start_point[2] = float(self.lineEdit_34.text())
            end_point[0] = float(self.lineEdit_31.text())
            end_point[1] = float(self.lineEdit_32.text())
            end_point[2] = float(self.lineEdit_35.text())
            section = self.comboBox_6.currentText()
            return start_point, end_point, section
        except:
            print("failed to read information")
            return [-1, -1], [-1, -1], ''

    def linear_planning(self):
        s, e, t = self.get_start_end_()
        if s[0] == -1:
            return
        else:
            pass

    def route_planning(self):
        s, e, t = self.get_start_end_()
        if s[0] == -1:
            return
        else:
            print("开始路径规划")
            # try:
            #     self.UDP_thread_route.quit()
            #     self.UDP_thread_route.terminate()
            # except:
            #     pass
            # self.UDP_thread_route = route_planning_threading.signal_from_route(self.ip, self.port - 10)
            # self.UDP_thread_route.signal_planning.connect(self.process_route)
            # self.UDP_thread_route.signal_warning.connect(self.process_route_inf)
            # self.UDP_thread_route.start()
            # try:
            #     self.route_plan.quit()
            #     self.route_plan.terminate()
            # except:
            #     pass
            # self.route_plan = route_planning_threading.route_planning(s, e, t, self.work_file, self.ip, self.port - 10)
            # self.route_plan.autoDelete()
            # self.route_plan_pool.start(self.route_plan)
            self.route_plan = route_planning_threading.Worker()
            z = [s, e, t, self.work_file]
            self.route_plan.point = z
            self.route_plan.ip = self.ip
            self.route_plan.port = self.port
            self.route_plan.signal_planning.connect(self.process_route)
            self.route_plan.signal_warning.connect(self.process_route_inf)
            self.route_plan.start()

    def process_route(self, p):
        self.progressBar_2.setValue(p)
        if p == 100:
            # 并且对文件的航向角进行一次处理
            if self.pushButton_41.isChecked():
                # 重新读取一次文件
                pass
            else:
                self.pushButton_41.click()

    def process_route_inf(self, q):
        self.label_38.setText(q)

    def init_planning_line_edit(self):
        self.lineEdit_26.returnPressed.connect(lambda: self.get_mark_point(1))
        self.lineEdit_30.returnPressed.connect(lambda: self.get_mark_point(1))
        self.lineEdit_31.returnPressed.connect(lambda: self.get_mark_point(2))
        self.lineEdit_32.returnPressed.connect(lambda: self.get_mark_point(2))

    def get_mark_point(self, log):
        self.process_route_inf('  ')
        if log == 1:
            self.lineEdit_26.setText(str(round(self.mark_x_planning, 4)))
            self.lineEdit_30.setText(str(round(self.mark_y_planning, 4)))
        elif log == 2:
            self.lineEdit_31.setText(str(round(self.mark_x_planning, 4)))
            self.lineEdit_32.setText(str(round(self.mark_y_planning, 4)))

    def clear_mark_planning_point(self):
        self.pen_0.removeItem(self.scatterItem_0)
        self.scatterItem_0.clear()
        self.pen_0.addItem(self.scatterItem_0)

    def init_planning_map(self):
        self.vertical_layout_0 = QVBoxLayout(self.widget)  # 在widget位置创建垂直布局
        self.win_0 = pg.GraphicsLayoutWidget(self.widget)  # 创建图形布局小部件
        self.widget_2.setWindowFlags(Qt.WindowStaysOnTopHint)
        self.win_0.setBackground((164, 208, 106))  # 定义背景颜色
        self.vertical_layout_0.addWidget(self.win_0)  # 放入垂直布局
        self.pen_0 = self.win_0.addPlot()  # 添加plot显示窗体
        self.pen_0.setAspectLocked()
        s1 = pg.ScatterPlotItem()
        s2 = pg.ScatterPlotItem()
        self.pen_0.showGrid(x=True, y=True)
        self.pen_0.setLabel(axis="left", text="<span style='font-size:16px;color:black;font-family: Arial'>y(m)</span>")
        self.pen_0.setLabel(axis="bottom",
                            text="<span style='font-size:16px;color:black;font-family: Arial'>x(m)</span>")
        myPen = pg.mkPen({'color': (0, 255, 0), 'width': 5})
        myPen2 = pg.mkPen({'color': (255, 0, 0), 'width': 5})
        self.pen_0.addItem(s1, pen=myPen, name="y2")
        self.pen_0.addItem(s2, pen=myPen2, name="y4")
        self.widget.lower()
        self.widget_2.raise_()
        self.change_tab()

    def change_tab(self):
        g = self.widget.geometry()
        self.widget_2.move(g.right() - self.widget_2.width() - 20, g.top() + 20)

    def resizeEvent(self, a0: QResizeEvent) -> None:
        self.change_tab()

    def init_mouse_pen_planning(self):
        self.win_0.scene().sigMouseClicked.connect(self.on_Mouse_Moved_planning)
        # 定义画笔颜色
        brush = pg.mkBrush(color=(185, 91, 84))
        self.scatterItem_0 = pg.ScatterPlotItem(pen=None, size=4, brush=brush, symbol='s')  # 标点按键列表
        self.pen_0.addItem(self.scatterItem_0)

    def on_Mouse_Moved_planning(self, evt):
        vb = self.pen_0.vb
        scene = evt.scenePos()
        if self.pen_0.sceneBoundingRect().contains(scene):
            mouse_point = vb.mapSceneToView(scene)
            x = round(float(mouse_point.x()), 4)
            y = round(float(mouse_point.y()), 4)
            if self.choose_dot_way_planning == 2:
                self.mark_x_planning = x
                self.mark_y_planning = y
                self.scatterItem_0.addPoints([x], [y])

    def exchange_planning_point_way(self):
        self.choose_dot_way_planning = self.comboBox_5.currentIndex()
        if self.choose_dot_way_planning == 1 and not self.UDP_lat_lon_coordinate[0] == -1:
            self.mark_x_planning = self.mark_x_convert
            self.mark_y_planning = self.mark_y_convert
            self.scatterItem_0.addPoints([self.mark_x_planning], [self.mark_y_planning])
